//
//  ViewController.m
//  11-16
//
//  Created by mac on 15-11-16.
//  Copyright (c) 2015年 ztt. All rights reserved.
//

#import "ViewController.h"
#import "QuartzCore/QuartzCore.h"
#import "TestViewController.h"
#import "IOSViewController.h"
@interface ViewController ()
{
    UILabel * l;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.title = @"电话簿";
    
    self.view.backgroundColor = [UIColor brownColor];
    
    l = [UILabel new];
    l.text = @"姓名";
    [l sizeToFit];
    l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
    l.textColor = [UIColor blackColor];
    [self.view addSubview:l];
}


- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:1 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
    }];
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = CGRectMake(50, 50, 100, 44);
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    UIButton * btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn2.frame = CGRectMake(30, 30, 50, 44);
    [btn2 setTitle:@"按钮1" forState:UIControlStateNormal];
    [btn2 setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    [btn2 addTarget:self action:@selector(onClick2:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn2];
}

- (void)onClick:(id)sender{
    TestViewController * con = [TestViewController new];
    [self.navigationController pushViewController:con animated:YES];
}

- (void)onClick1:(id)sender{
    [UIView animateWithDuration:1 animations:^{
        for (int i = 0 ; i<3; i++) {
            UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 0, 6)];
            line.backgroundColor = [UIColor blackColor];
            [self.view addSubview:line];
            line.frame = CGRectMake(i*20 + i*80, 0, 5, 150);
        }
    }completion:^(BOOL finish){
        for (int i = 0; i<3; i++) {
            UIView * line2 = [[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2.0, 0, 6, 0)];
            line2.backgroundColor = [UIColor blackColor];
            [self.view addSubview:line2];
            [UIView animateWithDuration:0.6 animations:^{
                line2.frame = CGRectMake(5, i*50+i*20, 200, 10);
            }];
        }
    }];
}

- (void)onClick2:(UIButton *)sender{
    IOSViewController * con = [IOSViewController new];
    [self.navigationController pushViewController:con animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
